<!--************************************************************************************************-->
<!-- < Group.php >                                                                               -->
<!-- Copyright (c) 2012-2013 San Yat-sun University School of Software                              -->
<!-- Modifier: Tianjiao Li                                                                 -->
<!-- Stu : 10389129                                                                                 -->
<!-- Date: 2012-01-01                                                                               -->
<!-- Destription :                                                           -->
<!--                                                                                                -->
<!-- Version : 2.2    
<!-- Last updated: 2013-01-02 by Xiaoxin Mo -->                                                                           
<!--************************************************************************************************-->

<?php
	include_once("../persistent/BaseObject.php");
	
	class Note extends BaseObject
	{
		public $page;
		public $content;
		public $Username;
		public $Bookname;
		//public $Thesisname;
		public $date;
		
		public function __construct($d)
		{
			$this->tableName = "Notes";
			parent::__construct($d);	
		}	
		
		public function findValueByUsername($Username)
		{
			$con = $this->openDB();
			
			// 找出Username的条目
			$sql = "SELECT * FROM $this->tableName
			WHERE Username = '$Username'";
			
			return $this->startSQL($sql,$con);
		}
		
		public function findValueByBookname($Bookname)
		{
			$con = $this->openDB();
			
			// 找出Username的条目
			$sql = "SELECT * FROM $this->tableName
			WHERE Bookname = '$Bookname'";
			
			return mysql_fetch_array($this->startSQL($sql,$con));
		}
		
		// find all the notes of the current user
		public function findNotelistByUseranme($Username)
		{
			$con = $this->openDB();
			
			$sql = "SELECT * FROM $this->tableName
			WHERE Username = '$Username'";
			
			return $this->startSQL($sql,$con);
		}
		
		// find the first N Notes of the current user
		public function findNNotesByUsername($Username, $N)
		{
			$con = $this->openDB();
			
			$sql = "SELECT * FROM $this->tableName
			WHERE Username = '$Username'
			LIMIT $N";
			
			return $this->startSQL($sql,$con);
		}
			
	}

?>
